Petrozavodsk Summer Training Camp 2016 Problem I. Vier 随机化+枚举

您所在的位置:网站首页 agency problem是什么 Petrozavodsk Summer Training Camp 2016 Problem I. Vier 随机化+枚举

Petrozavodsk Summer Training Camp 2016 Problem I. Vier 随机化+枚举

#Petrozavodsk Summer Training Camp 2016 Problem I. Vier 随机化+枚举| 来源: 网络整理| 查看: 265

Problem I. Vier

Input le: vier.inOutput le: vier.outTime limit: 2 secondsMemory limit: 256 mebibytes

The online game you've built in problem "Oha" involves n types of monsters. The monster types arenumbered from 1 to n, and a monster of i-th type has strength i and magical ability PAI[i]. All magicalabilities are di erent integers between 1 and n, inclusive, in other words, PAI is a permutation. Forsimplicity, you have generated this permutation uniformly at random.Now you need to choose the starting teams of monsters for the two sides of the game. Each side musthave exactly two monsters in the starting team (they can be of the same type), and the starting teamsmust be di erent. However, in order for the game to be balanced, the starting teams must have the sametotal strength modulo n and the same total magical ability modulo n.More formally, you need to nd four integers a, b, c and d between 1 and n such that:1. a + b == c + d (mod n), and2. PAIa + PAIb == PAIc + PAId (mod n).Note that the above statements are trivially true when a = c and b = d, or when a = d and b = c. Youneed to nd any other solution, or report that there isn't any. Note that it's allowed for some of the fourintegers to coincide | the only restriction is that they can't coincide in the two ways described in therst sentence of this paragraph.

InputThe rst line of the input le contains one integer n, 2


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3